package com.energyfuture.system.api;

import com.energyfuture.system.api.domain.SysCompany;
import com.energyfuture.system.api.domain.SysUser;
import com.energyfuture.system.api.model.SegmentEntity;
import com.energyfuture.system.api.model.SysparaEntity;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import com.energyfuture.common.core.constant.ServiceNameConstants;
import com.energyfuture.common.core.domain.R;
import com.energyfuture.system.api.factory.RemoteUserFallbackFactory;
import com.energyfuture.system.api.model.LoginUser;
import sun.security.util.SecurityConstants;

import java.util.List;

/**
 * 用户服务
 * 
 * @author energyfuture
 */
@FeignClient(contextId = "remoteUserService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteUserFallbackFactory.class)
public interface RemoteUserService
{
    /**
     * 通过用户名查询用户信息
     *
     * @param username 用户名
     * @return 结果
     */
    @GetMapping(value = "/user/info/{username}")
    public R<LoginUser> getUserInfo(@PathVariable("username") String username);
    
    /**
     * 通过用户ID查询用户信息
     *
     * @param userId 用户id
     * @return 结果
     */
    @GetMapping(value = "/user/selectUserById/{userId}")
    public R<SysUser> selectUserById(@PathVariable("userId") String userId);
    /**
     * 通过手机号查询用户信息
     *
     * @param phone 用户名
     * @return 结果
     */
    @GetMapping(value = "/user/selectUserByPhone/{phone}")
    public R<SysUser> selectUserByPhone(@PathVariable("phone") String phone);
    
    /**
     * 通过用户ID查询用户信息
     *
     * @param postCode 用户名
     * @param deptId 用户名
     * @return 结果
     */
    @GetMapping(value = "/user/selectUserNameByPostCodeAndDeptId/{postCode}/{deptId}")
    public R<List<String>> selectUserNameByPostCodeAndDeptId(@PathVariable("postCode") String postCode, @PathVariable("deptId") String deptId);

    
    /**
     * 查询系统参数
     *
     * @return 结果
     */
    @GetMapping(value = "/user/sysParam")
    public R<SysparaEntity> querySysParam();

    /**
     * 查询系统ips
     * @return
     */
    @GetMapping(value = "/user/sysIps")
    R<List<SegmentEntity>> selectSysIPs();


    @PostMapping(value = "/user/updateUser")
    R<Integer> updateUser(SysUser user);


    //添加
    /**
     * 注册用户信息
     *
     * @param sysUser 用户信息
     * @return 结果
     */
    @PostMapping("/user/register")
    public R<Boolean> registerUserInfo(@RequestBody SysUser sysUser);

    /**
     * 通过单位ID查询单位邀请码
     */
    @GetMapping("/{companyId}")
    public R<SysCompany> getCompanyInfo(@PathVariable String getCompanyID);

}
